<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>增加挂号</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" href="../../css/font.css">
    <link rel="stylesheet" href="../../css/xadmin.css">
    <script src="../../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../../js/xadmin.js"></script>
    <script src="../../js/common.js"></script>
</head>
<body>
<form class="layui-form " action="" lay-filter="example">
    <div class="layui-form-item">
        <label class="layui-form-label">患者姓名</label>
        <div class="layui-input-inline">
            <input type="text" name="pName" lay-verify="required" placeholder="请输入" autocomplete="off"
                   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item" style="width: 297px;">
        <label class="layui-form-label">患者性别</label>
        <div class="layui-input-block">
            <input type="radio" name="pGender" value="男" title="男" checked="">
            <input type="radio" name="pGender" value="女" title="女">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">年龄</label>
        <div class="layui-input-inline">
            <input type="text" name="pAge" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">手机号</label>
        <div class="layui-input-inline">
            <input type="text" name="pPhone" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item" style="width: 297px;">
        <label class="layui-form-label">医生选择</label>
        <div class="layui-input-block">
            <select name="doctorName" id="dotor" lay-filter="aihao">
                <option value="0">——请选择医生——</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item" style="width: 297px;">
        <label class="layui-form-label">科室选择</label>
        <div class="layui-input-block">
            <select name="rDepartment" id="divistion" lay-filter="aihao">
                <option value="">——请选择科室——</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item" style="width: 297px;">
        <label class="layui-form-label">初/复诊</label>
        <div class="layui-input-block">
            <input type="radio" name="rVisit" value="25" title="初诊" checked="">
            <input type="radio" name="rVisit" value="26" title="复诊">
        </div>
    </div>

    <div class="layui-form-item layui-form-text" style="width: 297px;">
        <label class="layui-form-label">过敏史</label>
        <div class="layui-input-block">
            <textarea placeholder="请输入内容" name="pAllergy" class="layui-textarea"></textarea>
        </div>
    </div>

    <div class="layui-form-item" style="width: 297px;">
        <label class="layui-form-label">有无慢性病</label>
        <div class="layui-input-block">
            <input type="radio" name="pChronic" value="6" title="无" checked="">
            <input type="radio" name="pChronic" value="7" title="有">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">身份证号码</label>
        <div class="layui-input-inline">
            <input type="text" name="idCard" lay-verify="required" placeholder="请输入" autocomplete="off"
                   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item layui-form-text" style="width: 297px;">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            <textarea placeholder="请输入内容" name="rRemarks" class="layui-textarea"></textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
        </div>
    </div>
</form>

</body>
</html>
<!--form表单提交-->
<script>
    layui.use(['form', 'layer', 'jquery', 'laydate'], function () {
        var form = layui.form,
            layer = layui.layer,
            laydate = layui.laydate;

        //监听提交
        form.on('submit(demo1)', function (data) {
            useAjax("/JT90/addpatient", data.field, "JSON", "GET", function (map) {
                if (map.success) {
                    if(map.patientNamberInfo!=null){
                        layer.msg(map.patientNamberInfo+':'+map.patientNamber+'人', {
                            time: 20000, //20s后自动关闭
                            btn: ['知道了']
                        });
                    }else{
                        layer.msg('添加成功', {
                            icon: 6,
                            time: 2000 //2秒关闭
                        }, function () {
                            //关闭当前frame
                            xadmin.close();
                            // 可以对父窗口进行刷新
                            xadmin.father_reload();
                        });
                    }
                } else {
                    layer.msg("添加失败", {icon: 5});
                }
            })
            return false;
        });


        $(function(){
            //发送ajax请求获取在职医生，在下拉列表加进去selectDivistion
            useAjax("/JT90/selectDotor", null, "JSON", "GET", function (map) {
                if (map.success) {
                    //医生  在下拉列表拼接数据  <option lay-value='"+item.rDepartment+"' selected>"+item.uName+"</option>
                    $.each(map.result, function (index, item) {
                        $('#dotor').append(new Option(item.uName,item.rDepartment));// 下拉菜单里添加元素
                    });
                    //科室
                    $.each(map.result2, function (index, item) {
                        $('#divistion').append(new Option(item.dName,item.dId));// 下拉菜单里添加元素
                    });
                    layui.form.render("select");
                }
            })
        })



    });
</script>

